-- @owner: @zou_jialiang050
-- @date: 2022/02/24
-- @testpoint: 在表上创建instead of insert on触发器，合理报错


--step1:建表;expect:成功
drop table if exists t_trigger_src_60 cascade;
drop table if exists t_trigger_des_60 cascade;
drop sequence if exists t_trigger_des_60_seq1 cascade;
create table t_trigger_src_60(id1 int, id2 int, id3 int) with (storage_type=ustore);
create table t_trigger_des_60(id1 int, id2 int, id3 int) with (storage_type=ustore);

--step2:在表上创建instead of insert on触发器;expect:合理报错
create sequence t_trigger_des_60_seq1;
create or replace function insert_func()
returns trigger as $$
begin
update t_trigger_src_60 set id1=10;
return new;
end;
$$language plpgsql;
/
drop trigger if exists insert_trigger_1 on t_trigger_src_60;
create trigger insert_trigger_1
instead of insert on t_trigger_src_60
for each row
execute procedure insert_func();
/

--step3:清理环境;expect:成功
drop trigger if exists insert_trigger_1 on t_trigger_src_60;
drop table if exists t_trigger_src_60 cascade;
drop table if exists t_trigger_des_60 cascade;
drop sequence if exists t_trigger_des_60_seq1 cascade;
drop function if exists insert_func;